import 'package:alice_screen/util/i18n/localizations.dart';
import 'package:alice_screen/widgets/load_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:pretty_qr_code/pretty_qr_code.dart';
import 'package:qr/qr.dart';

class GuideConfigWifi extends StatelessWidget {
  const GuideConfigWifi({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: <Widget>[
        Positioned(
          left: ScreenUtil().setWidth(30.0),
          top: ScreenUtil().setHeight(30.0),
          child: InkWell(
            onTap: () {
              
            },
            child: Icon(Icons.arrow_back_ios,
              color: Colors.white,
              size: ScreenUtil().setWidth(31.0),
            ),
          )
        ),
        Positioned.fill(
          child: Center(
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                SizedBox(width: ScreenUtil().setWidth(128.0),),
                qrCode(),
                SizedBox(width: ScreenUtil().setWidth(66.0),),
                Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Text(MyLocalizations.of(context).scanQrCode,
                      style: TextStyle(
                        color: Colors.white,
                        fontSize: ScreenUtil().setSp(28.0),
                        fontWeight: FontWeight.w500
                      ),
                    ),
                    SizedBox(height: ScreenUtil().setHeight(18.0),),
                    Text(MyLocalizations.of(context).distributionNetwork,
                      style: TextStyle(
                        color: Colors.white,
                        fontSize: ScreenUtil().setSp(44.0),
                        fontWeight: FontWeight.w500
                      ),
                    )
                  ]
                )
              ],
            )
          )
        )
      ],
    );
  }

  Widget qrCode() {
    return Container(
      alignment: Alignment.center,
      width: ScreenUtil().setWidth(280.0),
      height: ScreenUtil().setHeight(280.0),
      decoration: BoxDecoration(
        color: Color(0x56121C38),
        borderRadius: BorderRadius.circular(4),
        border: Border.all(color: Color(0x56FFFFFF), width: 2)
      ),
      child: Container(
        alignment: Alignment.center,
        width: ScreenUtil().setWidth(230.0),
        height: ScreenUtil().setHeight(230.0),
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(4)
        ),
        child: Stack(
          alignment: Alignment.center,
          children: <Widget>[
            PrettyQr(
              // image: AssetImage('images/app_launcher.png'),
              typeNumber: 3,
              size: ScreenUtil().setWidth(190.0),
              data: 'https://www.oschina.net/',
              errorCorrectLevel: QrErrorCorrectLevel.M,
            ),
            Container(
              alignment: Alignment.center,
              width: ScreenUtil().setWidth(58.0),
              height: ScreenUtil().setWidth(58.0),
              decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.circular(4)
              ),
              child: LoadAssetImage('app_launcher',
                width: ScreenUtil().setWidth(46.0),
                height: ScreenUtil().setHeight(46.0),
                fit: BoxFit.fill,
              ),
            )
          ]
        ),
      ),
    );
  }
}